<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="maintitle" :close-on-click-modal="false" class="tl-dialog" width="1000px" @open="open">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="流程图" name="first"><tl-approval-draw ref="approvalDraw" :sourceId="sourceId" :sourceType="sourceType"></tl-approval-draw></el-tab-pane>
      <el-tab-pane label="审批历史" name="second"><tl-approval-history ref="approvalHistory" :sourceId="sourceId" :sourceType="sourceType"></tl-approval-history></el-tab-pane>
    </el-tabs>
  </el-dialog>
</template>

<script>
/** 子组件 */
import tlApprovalDraw from './approvalDraw'
import tlApprovalHistory from './approvalHistory'
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
  components: { tlApprovalDraw, tlApprovalHistory },
  data() {
    return {
      urlPrefix: '/cbo/approvalFlowIns/',
      url: {
        // 额外的url
      },
      activeName: 'first',
      id: '',
      sourceId: '',
      sourceType: '',
      maintitle: '审批流程图',
      visible: false
    }
  },
  methods: {
    loaded() {
      // 页面加载完毕执行
      this.title = this.maintitle
    },
    open() {
      if (this.activeName === 'first') {
        this.$nextTick((_) => {
          this.$refs.approvalDraw.open()
        })
      } else if (this.activeName === 'second') {
        this.$nextTick((_) => {
          this.$refs.approvalHistory.open()
        })
      }
    },
    handleClick(tab, event) {
      if (tab.name === 'first') {
        this.$refs.approvalDraw.open()
      } else if (tab.name === 'second') {
        this.$nextTick((_) => {
          this.$refs.approvalHistory.open()
        })
      }
    }
  }
}
</script>
